package com.example.myapplication.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.myapplication.AnnouncementListBean;
import com.example.myapplication.R;

import org.w3c.dom.Text;

import java.util.List;

public class AnouncementsListAdapter extends BaseAdapter {
    List<AnnouncementListBean.DataBean> data;
    Context context;
    public AnouncementsListAdapter(List<AnnouncementListBean.DataBean> data, Context mcontext) {
        this.data = data;
        this.context = mcontext;
    }

    public AnouncementsListAdapter( ) {
    }
    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = LayoutInflater.from(context);
        //TODO 创建Item 文件
        View view = inflater.inflate(R.layout.annuncements_item,null);
        Log.e("TAG", "getView: "+        data.get(position).getTitle()
        );
        TextView tv = view.findViewById(R.id.tv_title_annuncement);
        tv.setText(data.get(position).getTitle());
        TextView time = view.findViewById(R.id.tv_time_annuncement);
        time.setText(data.get(position).getDate().toString());
        TextView docment = view.findViewById(R.id.tv_docment_annuncement);
        docment.setText(data.get(position).getDescription());
        return view;

    }
}
